package com.fxhy.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fxhy.bean.InviteCodeInfo;
import com.fxhy.mapper.InviteCodeInfoMapper;
import com.fxhy.repository.InviteCodeInfoRepository;

@Service
public class InviteCodeInfoService {
	@Autowired
	private InviteCodeInfoRepository InviteCodeInfoRepository;
	
	@Autowired
	private InviteCodeInfoMapper inviteCodeInfoMapper;
	
	public List<InviteCodeInfo> findInviteCodeInfoById(Integer userId) {
		return InviteCodeInfoRepository.findByUserId(userId);
	}

	public InviteCodeInfo saveInviteCode(InviteCodeInfo invite) {
		return InviteCodeInfoRepository.saveAndFlush(invite);
	}

	public Integer findCountSameAsInviteCode(String inviteCode) {
		return inviteCodeInfoMapper.findCountSameAsInviteCode(inviteCode);
	}
}
